const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const UserSchema = new Schema(
  {
    name: {
      type: String,
      required: true,
    },
    address: {
      type: String,
    },
    phone: {
      type: Number,
    },
    sex: {
      type: String,
    },
    email: {
      type: String,
    },
    pwd: {
      type: String,
    },
    desc: {
      type: String,
    },
  },
  {
    timestamps: true,
  }
);
const User = mongoose.model("user", UserSchema);
// mongoose
//   .connect("mongodb://localhost:27017/db-2101", {
//     useNewUrlParser: true,
//     useUnifiedTopology: true,
//   })
//   .then(() => {
//     console.log("连接成功");
//     User.find().then((res) => console.log(res));

//     const zhang = new User({
//       name: "张俊广",
//       desc: "优秀的不能再优秀",
//       address: "郑州市",
//       sex: "男",
//       phone: 17803878467,
//       email: "1457065548@qq.com",
//       pwd: "123456",
//     });
//     zhang.save().then((res) => console.log(res));
//   })
//   .catch((err) => console.log(err));

module.exports = User;
